import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int[] cost = new int[n + 1];
        for (int i = 1; i <= n; i++) cost[i] = in.nextInt();
        if (n <= 2) {
            System.out.println(cost[n]);
            return;
        }
        //dp[i]表示从第i阶阶梯出发所需要的最低花费
        //dp[i] = dp[]
        int[] dp = new int[n + 1];
        dp[1] = cost[1];
        for (int i = 2; i <= n; i++) {
            dp[i] = Math.min(dp[i-1],dp[i-2]) + cost[i];
        }
        System.out.println(Math.min(dp[n-1],dp[n]));
    }
}
